Skip to content

ssh: Remove nowarn_possibly_unsafe_function compile directives#11006

Open
u3s wants to merge 1 commit intoerlang:masterfrom
u3s:kuba/ssh/remove-unsafe-directives/OTP-20066
Open

ssh: Remove nowarn_possibly_unsafe_function compile directives#11006
u3s wants to merge 1 commit intoerlang:masterfrom
u3s:kuba/ssh/remove-unsafe-directives/OTP-20066

Conversation

@u3s
Copy link
Copy Markdown
Contributor

@u3s u3s commented Apr 13, 2026

Replace binary_to_atom/1 with binary_to_existing_atom/1 in ssh_transport (valid_key_sha_alg_ec/2, public_algo/1). The input comes from ssh_message:oid2ssh_curvename/1 which returns a fixed set of 5 binaries whose atoms already exist as literals in the same module.

Replace list_to_atom/1 with an explicit pattern match in ssh_connection (pty_default_dimensions/2). The Dimension argument is always the hardcoded atom width or height.

Add a justification comment for the kept file:consult/1 directive in ssh_options — the file path is operator-controlled, not from wire data.

Replace binary_to_atom/1 with binary_to_existing_atom/1 in
ssh_transport (valid_key_sha_alg_ec/2, public_algo/1). The input
comes from ssh_message:oid2ssh_curvename/1 which returns a fixed
set of 5 binaries whose atoms already exist as literals in the
same module.

Replace list_to_atom/1 with an explicit pattern match in
ssh_connection (pty_default_dimensions/2). The Dimension argument
is always the hardcoded atom width or height.

Add a justification comment for the kept file:consult/1 directive
in ssh_options — the file path is operator-controlled, not from
wire data.
@u3s u3s self-assigned this Apr 13, 2026
@u3s u3s added the team:PS Assigned to OTP team PS label Apr 13, 2026
@u3s u3s requested a review from Mikaka27 April 13, 2026 13:26
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 13, 2026

CT Test Results

    2 files     29 suites   27m 19s ⏱️
  499 tests   493 ✅  6 💤 0 ❌
1 708 runs  1 680 ✅ 28 💤 0 ❌

Results for commit 8fca863.

♻️ This comment has been updated with latest results.

To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.

See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.

Artifacts

// Erlang/OTP Github Action Bot

valid_key_sha_alg_ec(OID, Alg) when is_tuple(OID) ->
{SshCurveType, _} = ssh_message:oid2ssh_curvename(OID),
Alg == binary_to_atom(SshCurveType);
Alg == binary_to_existing_atom(SshCurveType);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this point, can you be sure that all the existing/valid SshCurveType values have already been "atomized"? That is, can you be sure that the valid atoms exist?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are only 5 SshCurveType binaries which can be returned by ssh_message:oid2ssh_curvename/1. all corresponding atoms are defined in ssh_transport:supported_algorithms/1 and ssh_transport:sha/1, and loaded to atom table upon loading ssh_transport beam module.

Copy link
Copy Markdown
Contributor

@juhlig juhlig Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... but in that case, if you know all the binaries you can get from that function and also the atoms they map to, why is this done through binary_to_existing_atom, instead of having a function like ssh_curvename_to_atom that turns one into the other, either in this module or in ssh_message?

Comment thread lib/ssh/src/ssh_transport.erl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team:PS Assigned to OTP team PS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants